package my.lotu.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import my.lotu.bean.Daymeal;
import my.lotu.bean.Food;
import my.lotu.bean.Meal;
import my.lotu.bean.Plan;
import my.lotu.dao.PlanDAO;
import my.lotu.util.PlanFactory;
@Transactional
public class PlanService implements IPlanService {
	private PlanDAO planDao;
	private PlanFactory planFactory;
	/**
	 * 通过planfactory获取生成的方案
	 * 通过plan去数据库查询对应的Daymeal集合
	 */
	@Override
	public List<Daymeal> getDayMealByPlan(Plan plan){
		plan=getPlanFactory().getPlan(plan);
		List<Daymeal> list= getPlanFactory().getDaymealList(plan);
		return list;
	}
	/**
	 * 通过Daymeal去获取对应的meal集合
	 */
	@Override
	public List<Meal> getMealByDaymeal(Daymeal daymeal){
		List<Meal> list=getPlanFactory().getMealList(daymeal);
		return list;
	}
	/**
	 * 通过meal去获取对应的food集合
	 */
	@Override
	public List<Food> getFoodByMeal(Meal meal){
		List<Food> list=getPlanFactory().getFoodByMeal(meal);
		return list;
	}
	
	/**
	 * setter和getter方法
	 * @return
	 */
	public PlanDAO getPlanDao() {
		return planDao;
	}
	public void setPlanDao(PlanDAO planDao) {
		this.planDao = planDao;
	}
	
	public PlanFactory getPlanFactory() {
		return planFactory;
	}
	public void setPlanFactory(PlanFactory planFactory) {
		this.planFactory = planFactory;
	}
	
	
}
